package com.lej.core.utils

import android.text.Spannable
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import com.lej.core.R
import com.lej.core.utils.extention.resColor
import com.lej.core.utils.extention.resString

/**
 *  author: cjq
 *  date  : 2022/6/15 0015
 *  desc  :
 */
object StringUtil {
    fun getString(res: Int, str: String): String = String.format(res.resString, str)

    fun getSpannableString(res: Int, str: String,startStr:String = "："): SpannableString {
        val string = res.resString
        val format = String.format(string, str)
        val spannableString = SpannableString(format)
        spannableString.setSpan(
            ForegroundColorSpan(R.color.textStressColor.resColor),
            format.indexOf(startStr)+1,
            format.length,
            Spannable.SPAN_INCLUSIVE_INCLUSIVE
        )
        return spannableString
    }
}